package com.huawei.hwCloudJs.service.locationapi;

import android.util.Log;
import com.baidu.location.BDLocation;
import com.huawei.hwCloudJs.core.JsCallback;
import com.huawei.hwCloudJs.service.locationapi.b.a;
import com.huawei.hwCloudJs.service.locationapi.bean.Address;
import com.huawei.hwCloudJs.service.locationapi.bean.Coordinates;
import com.huawei.hwCloudJs.service.locationapi.bean.LocOption;
import com.huawei.hwCloudJs.service.locationapi.bean.LocationInfo;

class GetLocationApi$1 implements a {
    final /* synthetic */ JsCallback a;
    final /* synthetic */ LocOption b;
    final /* synthetic */ GetLocationApi c;

    GetLocationApi$1(GetLocationApi getLocationApi, JsCallback jsCallback, LocOption locOption) {
        this.c = getLocationApi;
        this.a = jsCallback;
        this.b = locOption;
    }

    public void a(BDLocation bDLocation) {
        Log.i("GetLocationApi", "sendLocationMsg ok");
        if (bDLocation == null) {
            Log.i("GetLocationApi", "BDLocation Null");
            this.a.failure(4, "location null!");
            return;
        }
        GetLocationApi.a(this.c, bDLocation.getLongitude());
        GetLocationApi.b(this.c, bDLocation.getLatitude());
        if (0.0d == GetLocationApi.a(this.c) || 0.0d == GetLocationApi.b(this.c)) {
            this.a.failure(2, "getlocation failure!");
            return;
        }
        GetLocationApi.c(this.c);
        LocationInfo locationInfo = new LocationInfo();
        Coordinates coordinates = new Coordinates();
        GetLocationApi.a(this.c, coordinates, bDLocation);
        locationInfo.setCoordinates(coordinates);
        if (bDLocation.hasAddr() && this.b.getGeocode()) {
            Address address = new Address();
            GetLocationApi.a(this.c, address, bDLocation);
            locationInfo.setAddress(address);
            locationInfo.setAddresses(bDLocation.getAddrStr());
        }
        locationInfo.setCoordsType(bDLocation.getCoorType());
        locationInfo.setTimestamp(Long.valueOf(GetLocationApi.a(bDLocation.getTime())));
        this.a.success(locationInfo);
    }
}
